home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 5570 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.3 KB

  1. Path: netcad.enet.dec.com!branam
  2. From: branam@netcad.enet.dec.com ()
  3. Newsgroups: comp.lang.c++,comp.lang.c,comp.graphics.algorithms,comp.os.ms-windows.programmer.graphics
  4. Subject: Re: Urgent question
  5. Date: 5 Feb 1996 18:01:00 GMT
  6. Organization: Digital Equipment Corporation
  7. Distribution: world
  8. Message-ID: <4f5gks$76l@nntpd.lkg.dec.com>
  9. References: <4dg18o$lm4@news.ust.hk>
  10. Reply-To: branam@netcad.enet.dec.com ()
  11. NNTP-Posting-Host: kali.enet.dec.com
  12. X-Newsreader: mxrn 6.18-30
  13.  
  14.  
  15. To knit together several bitmaps into a single mosaic using MS-Windows GDI 
  16. routines, try the following general algorithm (assume 256-color bitmaps):
  17.  
  18.     Allocate memory for target bitmap data buffer: 1 byte per pixel.
  19.     For each source bitmap:
  20.            Allocate memory for source bitmap data buffer: 1 byte per pixel.
  21.            Construct BITMAPINFO block describing Device Independent Bitmap.
  22.        GetDIBits() using source bitmap handle, specifying
  23.                     source memory bitmap data buffer.
  24.            Compute offset into target data buffer of the starting XY coordinate
  25.                     for this bitmap.
  26.            Compute increment to next row of target data buffer.
  27.            Compute increment to next row of source data buffer (offset will
  28.                     start at 0).
  29.            For each row of source bitmap data:
  30.               Copy bits from source bitmap data buffer to current offset of 
  31.                         target buffer.
  32.               Add target increment to target offset.
  33.               Add source increment to source offset.
  34.            Endfor.
  35.            Free source bitmap data buffer.
  36.         Endfor.
  37.         Construct BITMAPINFO block for target bitmap.
  38.         CreateDIBitmap() using target data buffer to create a device dependent
  39.               bitmap, returning an HBITMAP.
  40.         Free target bitmap data buffer.
  41.  
  42. Compute the offsets, row widths, and increments for bitmap data buffer rows
  43. using the info in the BITMAPINFO blocks.
  44.  
  45. This requires memory for the entire target bitmap data buffer and one source
  46. bitmap data buffer at a time. Since these could be big, use fixed global memory
  47. blocks (there is no advantage to making them moveable because you are not
  48. keeping them around).
  49.  
  50. You also need to resolve the color palette if the bitmaps you are assembling 
  51. have different palettes. 
  52.